import { i18nRender } from '../locales'
// eslint-disable-next-line
import { BasicLayout } from '@/layouts'
import weixinRoutes from '@/config/routerModules/weixin'

const RouteView = {
  name: 'RouteView',
  render: (h) => h('router-view')
}

/**
 * 异步路由
 * breadBack: 带返回功能
 * breadTitle: 设置标题名称
 * breadHide: 当前页隐藏面包屑导航
 * showBread: 是否显示当前层级面包屑
 */
export const asyncRouterMap = [
  {
    path: '/',
    name: 'index',
    component: BasicLayout,
    redirect: '/overview/all',
    meta: { title: i18nRender('all.autotext821') },
    children: [
      {
        path: '/high',
        name: 'high',
        hidden: true,
        component: () => import('@/views/high/high.vue'),
        meta: { title: i18nRender('all.autotext1563'), icon: 'idcard', breadHide: true }
      },
      {
        path: '/overview',
        name: 'overview',
        component: () => import('@/views/overview/layout.vue'),
        redirect: '/overview/all',
        hideChildrenInMenu: true,
        meta: { title: i18nRender('all.autotext491'), icon: 'idcard' },
        children: [
          // 全部项目
          {
            path: '/overview/all',
            name: 'All',
            hidden: true,
            component: () => import('@/views/overview/index'),
            meta: { title: i18nRender('all.autotext1409'), keepAlive: false, breadHide: true }
          },
          // 项目详情
          {
            path: '/overview/detail',
            name: 'Responsible',
            component: () => import('@/views/overview/detail/responsible/index'),
            meta: { title: i18nRender('all.autotext519'), keepAlive: false, icon: 'appstore', permission: ['PROJECT'] }
          },
          // 项目看板
          {
            path: '/data/board',
            name: 'DataBoard',
            component: () => import('@/views/high/high'),
            meta: { title: i18nRender('all.autotext424'), keepAlive: false, icon: 'bar-chart', permission: ['BOARD'] }
          },
          // 费用申请->研究者
          {
            path: '/cost-apply/researcher-list',
            name: 'ResearcherList',
            component: () => import('@/views/cost-apply/researcher/ResearcherList'),
            meta: { title: i18nRender('all.autotext272'), keepAlive: false, icon: 'money-collect' }
          },
          {
            path: '/cost-add-researcher',
            name: 'AddResearcher',
            hidden: true,
            component: () => import('@/views/cost-apply/researcher/AddResearcher'),
            meta: { title: i18nRender('all.autotext705'), keepAlive: false }
          },
          // 费用申请->受试者
          {
            path: '/cost-apply/subject-list',
            name: 'SubjectList',
            component: () => import('@/views/cost-apply/subject/SubjectList'),
            meta: { title: i18nRender('all.autotext1635'), keepAlive: false, icon: 'money-collect' }
          },
          {
            path: '/cost-add-subject',
            name: 'AddSubject',
            hidden: true,
            component: () => import('@/views/cost-apply/subject/AddSubject'),
            meta: { title: i18nRender('all.autotext705'), keepAlive: false }
          },
          {
            path: '/cost-apply/apply-details',
            name: 'ApplyDetail',
            hidden: true,
            component: () => import('@/views/cost-apply/applyDetail'),
            meta: { title: i18nRender('all.autotext160'), keepAlive: false }
          },
          // 受试者管理
          {
            path: '/subject-manage',
            name: 'subjectManage',
            component: () => import('@/views/overview/layout.vue'),
            redirect: '/subject-manage-list',
            meta: { title: i18nRender('all.autotext433'), keepAlive: false, icon: 'contacts' },
            children: [
              {
                path: '/subject-manage-list',
                name: 'subjectManageList',
                component: () => import('@/views/overview/detail/responsible/components/subject'),
                meta: { title: i18nRender('all.autotext1676'), keepAlive: false }
              },
              {
                path: '/subject-manage-cancelList',
                name: 'cancelList',
                component: () => import('@/views/overview/cancelList'),
                meta: { title: i18nRender('all.autotext1844'), keepAlive: false }
              }
            ]
          },
          // 项目内费用审核
          {
            path: '/expense-audit',
            name: 'ExpenseAudit',
            component: () => import('@/views/cost-auditing/index'),
            meta: { title: i18nRender('all.autotext469'), keepAlive: false, icon: 'pay-circle' }
          },
          // 项目角色
          {
            path: '/project-role',
            component: () => import('@/views/system/index'),
            name: 'projectRole',
            meta: { title: i18nRender('all.autotext374'), keepAlive: false, icon: 'team', permission: ['SYSTEM'] }
          },
          // 项目日志
          {
            path: '/project-log',
            name: 'ProjectLog',
            component: () => import('@/views/system-log/index-new.vue'),
            meta: { title: i18nRender('all.autotext216.1'), keepAlive: false, icon: 'file-text', permission: ['LOG_LIST'] }
          },
          // 项目配置 使用 category 标签区分类别，需要根据类别做一些展示、隐藏操作
          {
            path: '/overview/config',
            name: 'Config',
            hidden: true,
            component: () => import('@/views/overview/layout.vue'),
            redirect: '/overview/config/index',
            hideChildrenInMenu: true,
            meta: { title: i18nRender('all.autotext905'), keepAlive: false, icon: 'setting', permission: ['PROJECT'], category: 'config', menuHidden: true, breadBack: true },
            children: [
              // 项目配置详情
              {
                path: '/overview/config/index',
                name: 'ConfigIndex',
                hidden: true,
                component: () => import('@/views/overview/project-config/index'),
                meta: { title: i18nRender('all.autotext905'), keepAlive: false, icon: 'setting', permission: ['PROJECT'], category: 'config', menuHidden: true, breadBack: true, showBread: false }
              },
              // 项目配置详情
              {
                path: '/overview/config/detail',
                name: 'ConfigDetail',
                hidden: true,
                component: () => import('@/views/overview/project-config/detail/index'),
                meta: { title: i18nRender('all.autotext1482'), keepAlive: false, icon: 'setting', permission: ['PROJECT'], category: 'config', menuHidden: true, breadBack: true }
              },
              // 项目配置新增角色
              {
                path: '/overview/config/addRole',
                name: 'ConfigAddRole',
                hidden: true,
                meta: { title: i18nRender('all.autotext1147'), icon: 'user', category: 'config', menuHidden: true, breadBack: true },
                component: () => import('@/views/overview/project-config/detail/components/role/addRole')
              },
              // 项目配置编辑角色
              {
                path: '/overview/config/editRole',
                name: 'ConfigEditRole',
                hidden: true,
                meta: { title: i18nRender('all.autotext1184'), icon: 'user', category: 'config', menuHidden: true, breadBack: true },
                component: () => import('@/views/overview/project-config/detail/components/role/editRole')
              },
              // 审批流程
              {
                path: '/overview/config/approvalSet',
                name: 'ConfigApprovalSet',
                hidden: true,
                component: () => import('@/views/overview/project-config/detail/components/approval/approvalSet'),
                meta: { title: i18nRender('all.autotext1286'), keepAlive: false, permission: ['PROJECT'], category: 'config', menuHidden: true, breadBack: true }
              },
              // 查看审批流程
              {
                path: '/overview/config/approvalDetail',
                name: 'ConfigApprovalDetail',
                hidden: true,
                component: () => import('@/views/overview/project-config/detail/components/approval/approvalDetail'),
                meta: { title: i18nRender('all.autotext377'), keepAlive: false, permission: ['PROJECT'], category: 'config', menuHidden: true, breadBack: true }
              }
            ]
          }
        ]
      },
      // 审批流程
      {
        path: '/approvalSet',
        name: 'approvalSet',
        hidden: true,
        component: () => import('@/views/overview/detail/responsible/components/approval/approvalSet'),
        meta: { title: i18nRender('all.autotext1286'), keepAlive: false, permission: ['PROJECT'], breadBack: true, menuHidden: true }
      },
      // 查看审批流程
      {
        path: '/approvalDetail',
        name: 'approvalDetail',
        hidden: true,
        component: () => import('@/views/overview/detail/responsible/components/approval/approvalDetail'),
        meta: { title: i18nRender('all.autotext377'), keepAlive: false, permission: ['PROJECT'], breadBack: true, menuHidden: true }
      },
      {
        path: '/overview/detail/treasure/payment-detail',
        name: 'PaymentDetail',
        hidden: true,
        component: () => import('@/views/cost-apply/applyDetail'),
        meta: { title: i18nRender('all.autotext1004'), keepAlive: false, permission: ['PROJECT'], breadBack: true, menuHidden: true }
      },
      {
        path: '/overview/detail/treasure/finance-detail',
        name: 'FinanceDetail',
        hidden: true,
        component: () => import('@/views/overview/detail/treasurer/components/finance/FinanceDetail'),
        meta: { title: i18nRender('all.autotext290'), keepAlive: false, permission: ['PROJECT'], breadBack: true, menuHidden: true }
      },
      // 费用管理
      {
        path: '/cost-auditing',
        name: 'costAuditing',
        component: () => import('@/views/cost-auditing/costAuditing'),
        meta: { title: i18nRender('all.autotext857'), keepAlive: false, icon: 'pay-circle', permission: ['FEE_REVIEW'], isSystem: true }
      },
      // 费用申请
      // {
      //   path: '/cost-apply',
      //   name: 'CostApply',
      //   hidden: true,
      //   component: () => import('@/views/cost-apply/index'),
      //   meta: { title: i18nRender('all.autotext246'), keepAlive: false, icon: 'money-collect' }
      // },
      // 组织机构
      {
        path: '/organization',
        name: 'organization',
        redirect: '/organization/sponsor',
        meta: { title: i18nRender('all.autotext785'), keepAlive: false, icon: 'apartment', permission: ['ORGANIZATION'], isSystem: true },
        component: () => import('@/views/overview/layout.vue'),
        children: [
          {
            path: '/organization/sponsor',
            name: 'organizationSponsor',
            hidden: true,
            component: () => import('@/views/organization/components/SponsorTab'),
            meta: { title: i18nRender('all.autotext754'), keepAlive: true, isSystem: true }
          },
          {
            path: '/organization/siteTab',
            name: 'organizationSiteTab',
            hidden: true,
            component: () => import('@/views/organization/components/SiteTab'),
            meta: { title: i18nRender('all.autotext163'), keepAlive: true, isSystem: true }
          }
        ]
      },
      // 系统管理
      // {
      //   path: '/system',
      //   component: () => import('@/views/system/index'),
      //   name: 'system',
      //   meta: { title: i18nRender('all.autotext1082'), keepAlive: false, icon: 'team', permission: ['SYSTEM'], isSystem: true }
      // },
      // 系统管理
      {
        path: '/system',
        component: () => import('@/views/overview/layout.vue'),
        name: 'system',
        redirect: '/system/user',
        meta: { title: i18nRender('all.autotext1082'), keepAlive: false, icon: 'team', permission: ['SYSTEM'], isSystem: true },
        children: [
          // 账户管理
          {
            path: '/system/user',
            name: 'systemUser',
            component: () => import('@/views/system/components/user'),
            meta: { title: i18nRender('all.autotext1144'), keepAlive: true, isSystem: true }
          },
          // 角色权限
          {
            path: '/system/role',
            name: 'systemRole',
            component: () => import('@/views/system/components/role'),
            meta: { title: i18nRender('all.autotext893'), keepAlive: true, isSystem: true }
          },
          // 权限管理
          {
            path: '/system/roleManagement',
            name: 'systemRolemanagement',
            component: () => import('@/views/system/components/roleManagement'),
            meta: { title: i18nRender('all.autotext648'), keepAlive: true, isSystem: true }
          },
          // 其他设置
          {
            path: '/system/setting',
            name: 'systemSetting',
            component: () => import('@/views/system/components/setting'),
            meta: { title: i18nRender('all.autotext463'), keepAlive: true, isSystem: true }
          },
          // 数据状态权限
          {
            path: '/system/datapms',
            name: 'systemDatapms',
            component: () => import('@/views/system/components/data-pms'),
            meta: { title: i18nRender('all.autotext312'), keepAlive: true, isSystem: true }
          },
          // 用户反馈
          {
            path: '/system/feedcenter',
            name: 'feedCenter',
            component: () => import('@/views/feedcenter/feedcenter'),
            meta: { title: i18nRender('all.autotext1493'), keepAlive: true, isSystem: true }
          }
        ]
      },
      // 添加角色
      {
        path: '/addRole',
        name: 'AddRole',
        hidden: true,
        meta: { title: i18nRender('all.autotext1290'), icon: 'user', menuHidden: true, breadBack: true },
        component: () => import('@/views/system/addRole')
      },
      // 编辑角色
      {
        path: '/editRole',
        name: 'EditRole',
        hidden: true,
        meta: { title: i18nRender('all.autotext1184'), icon: 'user', menuHidden: true, breadBack: true },
        component: () => import('@/views/system/editRole')
      },
      // 系统日志
      // {
      //   path: '/system-log',
      //   name: 'SystemLog',
      //   component: () => import('@/views/system-log/index-new.vue'),
      //   meta: { title: i18nRender('all.autotext594'), keepAlive: false, icon: 'file-text', permission: ['LOG_LIST'], isSystem: true }
      // },
      // 系统日志
      {
        path: '/system-log',
        name: 'SystemLog',
        redirect: '/system/systemLoginLog',
        component: () => import('@/views/overview/layout.vue'),
        meta: { title: i18nRender('all.autotext594'), keepAlive: false, icon: 'file-text', permission: ['LOG_LIST'], isSystem: true },
        children: [
          // 系统登录日志
          {
            path: '/system/systemLoginLog',
            name: 'SystemLoginLog',
            component: () => import('@/views/system-log/components/SystemLoginLog.vue'),
            meta: { title: i18nRender('all.autotext1525'), keepAlive: true, isSystem: true }
          },
          // 系统操作日志
          {
            path: '/system/systemOperatorLog',
            name: 'SystemOperatorLog',
            component: () => import('@/views/system-log/components/SystemOperatorLog.vue'),
            meta: { title: i18nRender('all.autotext1267'), keepAlive: true, isSystem: true }
          },
          // 系统导出日志
          {
            path: '/system/systemExportLog',
            name: 'SystemExportLog',
            component: () => import('@/views/system-log/components/SystemExportLog.vue'),
            meta: { title: i18nRender('all.autotext752'), keepAlive: true, isSystem: true }
          }
        ]
      },
      // 系统通知
      {
        path: '/system-notice',
        name: 'SystemNotice',
        // component: () => import(/* webpackChunkName: 'sys-notice' */ '@/views/system-notice/index.vue'),
        component: () => import('@/views/overview/layout.vue'),
        meta: { title: i18nRender('all.autotext841'), keepAlive: false, icon: 'bell', permission: ['SYSTEM_NOTICE'], isSystem: true },
        children: [
          // 系统通知
          {
            path: '/system/systemNotify',
            name: 'systemNotify',
            component: () => import('@/views/system-notice/system-notify.vue'),
            meta: { title: i18nRender('all.autotext841'), keepAlive: true, isSystem: true }
          }
        ]
      },
      {
        path: '/system-notice/details/:id',
        name: 'SystemNoticeDetails',
        props: true,
        hidden: true,
        component: () => import(/* webpackChunkName: 'sys-notice' */ '@/views/system-notice/components/feedback-detail.vue'),
        meta: { title: i18nRender('all.autotext684'), permission: ['SYSTEM_NOTICE'] }
      },
      // 入账管理
      {
        path: '/entry',
        name: 'entry',
        component: () => import('@/views/entry/index'),
        meta: { title: i18nRender('all.autotext1715'), keepAlive: false, icon: 'account-book', permission: ['ACCOUNTING_MANAGEMENT'] }
      },
      {
        path: '/site',
        name: 'site',
        hidden: true,
        component: () => import('@/views/site/index.vue'),
        meta: { title: i18nRender('all.autotext879'), icon: 'idcard', breadHide: true }
      },
      // Exception
      {
        path: '/exception',
        name: 'exception',
        component: RouteView,
        redirect: '/exception/403',
        meta: { title: 'menu.exception', icon: 'warning', permission: ['exception'] },
        children: [
          {
            path: '/exception/403',
            name: 'Exception403',
            component: () => import(/* webpackChunkName: "fail" */ '@/views/exception/403'),
            meta: { title: 'menu.exception.not-permission', permission: ['exception'] }
          },
          {
            path: '/exception/404',
            name: 'Exception404',
            component: () => import(/* webpackChunkName: "fail" */ '@/views/exception/404'),
            meta: { title: 'menu.exception.not-find', permission: ['exception'] }
          },
          {
            path: '/exception/500',
            name: 'Exception500',
            component: () => import(/* webpackChunkName: "fail" */ '@/views/exception/500'),
            meta: { title: 'menu.exception.server-error', permission: ['exception'] }
          }
        ]
      },
      // account
      {
        path: '/settings',
        name: 'settings',
        hidden: true,
        meta: { title: i18nRender('all.autotext1221'), icon: 'user', keepAlive: false, breadBack: true, menuHidden: true },
        component: () => import('@/views/account/settings/index-new.vue')
      },
      // 费用记录
      {
        path: '/recordDetail',
        name: 'RecordDetail',
        hidden: true,
        meta: { title: i18nRender('all.autotext266'), icon: '', keepAlive: false, breadBack: true, menuHidden: true },
        component: () => import('@/views/account/settings/entrance/record/detail/index')
      },
      // 合同详情
      {
        path: '/contract/detail',
        name: 'ContractDetail',
        hidden: true,
        meta: { title: i18nRender('all.autotext432'), icon: '', keepAlive: false },
        component: () => import('@/views/account/settings/entrance/contract/detail/index')
      },
      // 待办中心
      {
        path: '/todo',
        name: 'todo',
        hidden: true,
        meta: { title: i18nRender('all.autotext1694'), keepAlive: false, icon: 'apartment', breadBack: true, menuHidden: true },
        component: () => import('@/views/todo/todo')
      },
      // 消息
      {
        path: '/message',
        name: 'message',
        hidden: true,
        meta: { title: i18nRender('all.autotext170'), icon: 'apartment', breadBack: true, menuHidden: true },
        component: () => import('@/views/message/message')
      },
      // 用户反馈
      {
        path: '/feedback',
        name: 'feedback',
        hidden: true,
        meta: { title: i18nRender('all.autotext1493'), breadBack: true, menuHidden: true },
        component: () => import('@/views/feedback/feedback')
      },
      {
        path: '/permissionsSet',
        name: 'permissionsSet',
        hidden: true,
        meta: { title: '权限辅助', menuHidden: true },
        component: () => import('@/views/system/permissionsSet')
      }
    ]
  },
  {
    path: '*',
    redirect: '/404',
    hidden: true
  },
  // 完善个人信息
  {
    path: '/person',
    name: 'Person',
    hidden: true,
    meta: { title: i18nRender('all.autotext1358'), keepAlive: false, icon: 'apartment' },
    component: () => import('@/views/person/Index')
  }
]

/**
 * 基础路由
 * @type { *[] }
 */
export const constantRouterMap = [
  {
    path: '/user/login',
    name: 'login',
    component: () => import(/* webpackChunkName: "user" */ '@/views/user/Login'),
    hidden: true
  },
  {
    path: '/privacy',
    name: 'privacy',
    component: () => import(/* webpackChunkName: "user" */ '@/views/system/privacy'),
    hidden: true
  },
  {
    path: '/404',
    component: () => import(/* webpackChunkName: "fail" */ '@/views/exception/404')
  },
  {
    path: '/403',
    component: () => import(/* webpackChunkName: "fail" */ '@/views/exception/403')
  },
  {
    path: '/attestation',
    name: 'attestation',
    hidden: true,
    component: () => import('@/views/attestation/Index')
  },
  {
    path: '/jump-mp',
    name: 'jumpMp',
    component: () => import(/* webpackChunkName: "fail" */ '@/views/JumpMp')
  },
  {
    path: '/loginByToken',
    name: 'loginByToken',
    component: () => import('@/views/loginByToken')
  },
  {
    path: '/transfer-page',
    name: 'transferPage',
    component: () => import('@/views/transferPage/index.vue')
  },
  // h5 个人授权书和隐私政策
  {
    path: '/privaOfAu',
    name: 'privaOfAu',
    hidden: true,
    component: () => import('@/views/attestation/components/privaOfAu')
  },
  ...weixinRoutes
]
